package indi.h.filefilter;

import java.io.File;
import java.util.Map;

import org.apache.log4j.Logger;

import indi.h.filefilter.anaysis.Anaysis;
import indi.h.filefilter.anaysis.SimpleAnaysis;
import indi.h.filefilter.callables.InterceptorCallable;
import indi.h.filefilter.enums.FileEnum;
import indi.h.filefilter.filters.BasicFilters;
import indi.h.filefilter.filters.Filter;
import indi.h.filefilter.filters.StrFilter;
import indi.h.filefilter.filters.Filter.FilterR;
import indi.h.filefilter.interceptors.Interceptor;
import indi.h.filefilter.listeners.InterceptorListener;

public class BasicFileInterceptor implements Interceptor {
	private final static Logger l = Logger.getLogger(BasicFileInterceptor.class);

	private BasicFilters bff;
	private Anaysis ana;
	private String file;

	public BasicFileInterceptor() {
		bff = new BasicFilters();
	}

	public void setCustomF(Filter f) {
		bff.setFilter(f);
	}

	public void setSizeF(Map<String, Long> m) {

	}

	public void setNameF(String[] terms) {

	}

	public void setTypeF(String[] terms) {

	}

	public void setContentF(String[] terms) {
		bff.setFilter(new StrFilter(FileEnum.CONTENT, terms));
	}

	public FilterR intercept(String file, InterceptorListener il) {
		// TODO Auto-generated method stub
		this.ana = SimpleAnaysis.getSimpleAnaysis(this.bff);
		this.file = file;
		//return new InterceptorCallable(this,il);
		return intercept();
	}

	@Override
	public FilterR intercept() {
		// TODO Auto-generated method stub
		return this.ana.anaysis(new File(file));
	}

}
